home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / lang / fortran / pgplot5.1 / pgplot5 / pgplot5.1.0 / examples-src / pgdemo11.f < prev    next >
Encoding:
Text File  |  1994-11-15  |  3.0 KB  |  102 lines

  1.       PROGRAM PGDE11
  2. C-----------------------------------------------------------------------
  3. C Demonstration program for PGPLOT: travelling sine wave.
  4. C
  5. C This program illustrates how animated displays can be generated with
  6. C PGPLOT, although PGPLOT is not optimized for such use.
  7. C
  8. C To create an animated display:
  9. C
  10. C  (1) Do not call PGPAGE (or PGENV, which calls PGPAGE) between frames;
  11. C  (2) Enclose all the calls required to generate each frame between
  12. C      PGBBUF and PGEBUF calls;
  13. C  (3) Either: erase the entire previous frame by calling PGERAS before
  14. C      drawing the next frame; or: erase the parts of the frame that
  15. C      have changed by overwriting with the background color (color
  16. C      index 0).
  17. C
  18. C This program demonstrated both approaches. Using PGERAS is usually
  19. C slower, because more has to be redrawn in each frame. Erasing selected
  20. C parts of the display can be faster, but it may be difficult to avoid
  21. C erasing parts that should remain visible.
  22. C
  23. C This program requires an interactive display that supports writing
  24. C in color index 0.
  25. C-----------------------------------------------------------------------
  26. C Parameters:
  27. C   NT is the number of frames in the animation.
  28.       INTEGER N,NT
  29.       REAL A,B
  30.       PARAMETER (N = 50)
  31.       PARAMETER (NT = 100)
  32.       PARAMETER (A = 2.0*3.1415927/N)
  33.       PARAMETER (B = 2.0*3.1415927/NT)
  34. C Variables:
  35.       REAL X(0:N), Y(0:N)
  36.       INTEGER I, T, L
  37.       CHARACTER*8 STR
  38.       INTEGER PGBEG
  39. C-----------------------------------------------------------------------
  40.  
  41.       WRITE (*,*) 'Demonstration of animation with PGPLOT'
  42.       WRITE (*,*) 'This program requires an interactive display that'
  43.       WRITE (*,*) 'supports writing in color index 0.'
  44.  
  45.       IF (PGBEG(0,'?',1,1) .NE. 1) STOP
  46.  
  47.       CALL PGQINF('HARDCOPY', STR, L)
  48.       IF (STR(:L).NE.'NO') WRITE (*,*)
  49.      :     'Warning: device is not interactive'
  50.  
  51.       WRITE (*,*) '1: erasing the entire screen between frames'
  52.  
  53.       CALL PGPAGE
  54.       CALL PGVSTD
  55.       CALL PGWNAD(-A, A*(N+1), -1.1, 1.1)
  56.       
  57.       DO 200 T=0,NT
  58.         CALL PGBBUF
  59.         CALL PGERAS
  60.         CALL PGSCI(1)
  61.         CALL PGBOX('bcnst', 0.0, 0, 'bcnst', 0.0, 0)
  62.         DO 100 I=0,N
  63.           X(I) = I*A 
  64.           Y(I) = SIN(I*A-T*B)  
  65.   100   CONTINUE
  66.         CALL PGSCI(3)
  67.         CALL PGLINE(N+1,X,Y)
  68.         WRITE (STR,'(I8)') T
  69.         CALL PGMTXT('T', 2.0, 0.0, 0.0, STR)
  70.         CALL PGEBUF
  71.   200 CONTINUE
  72.  
  73.       WRITE (*,*) '2: erasing only the line between frames'
  74.  
  75.       CALL PGPAGE
  76.       CALL PGVSTD
  77.       CALL PGWNAD(-A, A*(N+1), -1.1, 1.1)
  78.       CALL PGBBUF
  79.       CALL PGSCI(1)
  80.       CALL PGBOX('bcnst', 0.0, 0, 'bcnst', 0.0, 0)
  81.       DO 300 I=0,N
  82.          X(I) = I*A 
  83.          Y(I) = SIN(I*A)  
  84.  300  CONTINUE
  85.       CALL PGEBUF
  86.    
  87.       DO 500 T=0,NT
  88.         CALL PGBBUF
  89.         CALL PGSCI(0)
  90.         CALL PGLINE(N+1,X,Y)
  91.         CALL PGSCI(3)
  92.         DO 400 I=0,N
  93.           X(I) = I*A 
  94.           Y(I) = SIN(I*A-T*B)  
  95.   400   CONTINUE
  96.         CALL PGLINE(N+1,X,Y)
  97.         CALL PGEBUF
  98.   500 CONTINUE
  99.  
  100.       CALL PGEND
  101.       END
  102.